/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.emex.app.stuff.provider;

import com.emex.app.stuff.utils.UIUtils;
import java.net.MalformedURLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Wrapping for method of getting web service. It needed for catch of any
 * exceptions.
 *
 * @author Alexey Pashkin
 */
public abstract class RequestWebService {

    private static final Logger logger
            = LoggerFactory.getLogger(RequestWebService.class);

    public void doRequest() {
        try {
            doRequestBody();
        } catch (MalformedURLException ex) {
            logger.error(ex.getMessage(), ex);
            UIUtils.showErrorMessage("Сервер недоступен. Обратитесь к администратору");
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
            UIUtils.showErrorMessage("Сервер недоступен. Обратитесь к администратору");
        }
    }

    abstract protected void doRequestBody() throws MalformedURLException;
}
